|
|
|
|
|
|
|
The program also uses a toolbar to let the user select commands using buttons. The buttons invoke the corresponding menu items. For instance, the following code fragment shows how the program responds when the user clicks the bold toolbar button. The rest of the ButtonClick event handler is similar. |
|
|
|
 |
|
|
|
|
' Execute a command. Private Sub tbrButtons_ButtonClick( _
ByVal Button As ComctlLib.Button)
Select Case Button.Key
:
Case "Bold"
mnuFontBold_Click
:
End Select
End Sub |
|
|
|
|
|
|
|
|
When the user changes the selection in the rich text box, the control's SelChange event handler executes. It examines the control's properties to determine which menu items should be checked and which toolbar buttons should be depressed. The following code fragment shows how the program handles the selected text's bold property. The rest of the subroutine handles other button presses in a similar way. |
|
|
|
 |
|
|
|
|
'Set the menu item and button states for the
' selected text. Private Sub rchText_SelChange()
:
If rchText.SelBold Then
tbrButtons.Buttons("Bold").value = tbrPressed
mnuFontBold.Checked = True
Else
tbrButtons.Buttons("Bold").value = tbrUnpressed
mnuFontBold.Checked = False
End If
:
tbrButtons.Refresh
End Sub |
|
|
|
|
|
|
|
|
Visual Basic's normal text handling methods are good enough in most circumstances. Labels let a program display static text. Using multiple labels, a program can display static text using multiple fonts and colors. |
|
|
|
|
|
|
|
|
To display more complex text, a program can use the CreateFont API function. This function is very complicated, however, so you should use normal Visual Basic methods if possible. |
|
|
|
|
|